#include<stdio.h>
#include<string.h>

int main()
{
	int n,l,k,y,i,j,a[100];
	char s[120];
	memset(a,0,sizeof(a));
	scanf("%d%d%d%d",&n,&l,&k,&y);
	int sum1,sum2,sum3;
	sum1=l+k+y;
	sum2=2*l+k;
	sum3=3*l+3*k+2*y;
	for (i=0;i<n;i++)
	{
		scanf("%s",s);
		int len;
		len=strlen(s);
		for (j=0;j<len;j++)
		{
			if (s[j]=='A')
				a[i]+=sum1;
			if (s[j]=='B')
				a[i]+=sum2;
			if (s[j]=='C')
				a[i]+=sum3;
		}
	}
	int minimum=a[0];
	for (i=1;i<n;i++)
		if (minimum>a[i])
			minimum=a[i];
	printf("%d\n",minimum);
	return 0;
}
